package piwan.gui;

import org.fenggui.Button;
import org.fenggui.event.mouse.MouseEnteredEvent;
import org.fenggui.text.content.factory.simple.TextStyle;

public class SmartButton extends Button {
	private TextStyle stEnabled,stDisabled;
	
	public SmartButton() {
		super();
		
	}
	
	void init(String text) {
		setText(text);
		stEnabled = getAppearance().getStyle("enabled");
		stDisabled = getAppearance().getStyle("disabled");
	}
	
	public void setEnabled( boolean e ) {
		super.setEnabled(e);
		
		if(e)
			getAppearance().addStyle("default", stEnabled);
		else {
			getAppearance().setEnabled("pressed", false);
			getAppearance().addStyle("default", stDisabled);
		}
	}
	
	public void mouseEntered(MouseEnteredEvent mouseEnteredEvent) {	
		if( isEnabled() )
			super.mouseEntered(mouseEnteredEvent);
	}
	/*
	public void mouseExited(MouseEnteredEvent mouseEnteredEvent) {
		
		super.mouseExited(mouseEnteredEvent);
	}*/
}
